<template>
	<view>
    <uni-popup
        id="popup"
        ref="popup"
        type="message"
    >
      <uni-popup-message :type=type :message=message :duration=duration ></uni-popup-message>
    </uni-popup>
  </view>
</template>

<script>
	export default {
		data() {
      return {
        type: 'success',
        message: '',
        duration: 2000,
        reDefault() {
          this.type = 'success'
          this.message = ''
          this.duration = 2000
        },
      }
		},
		methods: {
			open(type,message,duration){
			  this.type = type
        this.message = message
        this.duration = duration
        this.$refs.popup.open();
      },
      success(message,duration = 2000){
        this.open('success',message,duration)
      },
      warn(message,duration = 2000){
        this.open('warn',message,duration)
      },
      error(message,duration = 3000) {
        this.open('error',message,duration)
      },
      info(message,duration = 2000){
        this.open('info',message,duration)
      }
    }
	}
</script>

<style lang="scss">
</style>
